/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { GeometryTransitionView } from '@hadss/react_native_geometry_transition';
import React, { useRef } from 'react';
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';
import SampleTurboModule from '../basic/SampleTurboModule';

const FeaturesListPage = (): JSX.Element => {
  const nativeRef = useRef<any>(null);
  const handlePress = (bundlePath: string, moduleName: string): void => {
    const timestamp = Date.now().toString();
    SampleTurboModule.pushStringToHarmony(`${bundlePath}, ${moduleName}, ${timestamp}`, 1);
  };

  return (
    <View style={styles.container}>
      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 12 }]}
        geometryViewID={'test'}
        ref={nativeRef}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={(): void => handlePress('bundle/knockshare.harmony.bundle', 'KnockSharePage')}>
          <Text style={{ color: 'white' }}>碰一碰分享</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={(): void => handlePress('bundle/intents.harmony.bundle', 'IntentsPage')}>
          <Text style={{ color: 'white' }}>意图框架</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={(): void => handlePress('bundle/vibrator.harmony.bundle', 'VibratorPage')}>
          <Text style={{ color: 'white' }}>鸿蒙振动</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={() => handlePress('bundle/movingPhoto.harmony.bundle', 'MovingPhotoPage')}>
          <Text style={{ color: 'white' }}>动态图片</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={() => handlePress('bundle/picker.harmony.bundle', 'PickerPage')}>
          <Text style={{ color: 'white' }}>Picker</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={() => handlePress('bundle/mediaProcessing.harmony.bundle', 'MediaProcessingPage')}>
          <Text style={{ color: 'white' }}>图片增强</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={(): void => handlePress('bundle/folderStack.harmony.bundle', 'FoldSplitContainerPage')}>
          <Text style={{ color: 'white' }}>折叠容器 - 额外分栏</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={(): void => handlePress('bundle/folderStack.harmony.bundle', 'FolderStackPage')}>
          <Text style={{ color: 'white' }}>折叠容器 - 上下分栏</Text>
        </TouchableOpacity>
      </GeometryTransitionView>

      <GeometryTransitionView
        style={[styles.buttonContainer, { marginBottom: 16 }]}
        geometryViewID={'test'}
        pageType={'current'}>
        <TouchableOpacity
          style={styles.btn}
          onPress={(): void => handlePress('bundle/pasteBoard.harmony.bundle', 'PasteBoardPage')}>
          <Text style={{ color: 'white' }}>剪切板</Text>
        </TouchableOpacity>
      </GeometryTransitionView>
    </View>
  );
};

export default FeaturesListPage;

const styles = StyleSheet.create({
  container: {
    justifyContent: 'flex-end', // 垂直居中
    alignItems: 'center', // 水平居中
    width: '100%',
    height: '100%',
    paddingBottom: 26,
  },
  buttonContainer: {
    width: '90%',
    marginVertical: 10,
    height: 40, // 控制按钮高度
    borderRadius: 20,
    overflow: 'hidden',
  },
  btn: {
    height: 40,
    backgroundColor: 'rgb(10, 89, 247)',
    display: 'flex',
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
});
